﻿// wwwroot/js/canvasInterop.js  
window.canvasInterop = {
    drawLine: function (startX, startY, endX, endY, color) {
        const canvas = document.getElementById('myCanvas');
        if (!canvas || !canvas.getContext) return;

        const ctx = canvas.getContext('2d');
        ctx.beginPath();
        ctx.moveTo(startX, startY);
        ctx.lineTo(endX, endY);
        ctx.strokeStyle = color;
        ctx.lineWidth = 2;
        ctx.stroke();
        ctx.closePath(); // 清除路径以准备下一次绘制  
    }
};